C     COPYRIGHT       NONE.  THIS CODE IS IN THE PUBLIC DOMAIN.
C     FILENAME        GEMINICATCHUPANDRENDEZVOUSPROGRAM/RNDZ.F
C     PURPOSE         THIS IS PART OF THE ORIGINAL 1965 SIMULATION 
C                     PROGRAM FOR THE GEMINI 7/6 MISSION
C                     CATCH-UP AND RENDEZVOUS FLIGHT PHASES.
C                     THIS PARTICULAR FILE CONTAINS ONLY THE
C                     RNDZ SUBROUTINE (RENDEZVOUS FOR MODULE 5
C                     OF MATH FLOW 7), BY FERNEY HOUGH AND
C                     REINER.
C     WEBSITE         WWW.IBIBLIO.ORG/APOLLO
C     HISTORY         2010-08-14 RSB  BEGAN TRANSCRIBING FROM
C                                     THE SCANNED PDF REPORT.
C
C     REFER TO MAIN.F FOR MORE-DETAILED INTRODUCTORY COMMENTS.
C
C     FROM PAGE 95 OF THE REPORT 
      SUBROUTINE RNDZ
      DIMENSION CXT(11),CYT(11),CZT(11),CDTWT(11)
      COMMON CDVXSP,CDVYSP,CDVZSP,CDPHSC,CDPSSC,CDTHSC,AKX1  ,AKX2  ,
     1AKX3  ,AKX4  ,AKYI  ,AKY2  ,AKY3  ,AKY4  ,AKZI  ,AKZ2  ,AKZ3  ,
     2AKZ4  ,ASFX  ,ASFY  ,ASFZ  ,CO    ,COI   ,C2    ,C2I   ,CA11  ,
     3CA12  ,CAI3  ,CA21  ,CA22  ,CA23  ,CA31  ,CA32  ,CA33  ,CAPT  ,
     4CAPTI ,CATXBA,CATXBI,CCAB  ,CCABI ,CCAS  ,CCAS1 ,CCK1  ,CCK2  ,
     5CCK3  ,CCK4  ,CCKS  ,CCKF  ,CCKG  ,CCPHIB,CCPSIB,CCPSIR,CCR   ,
     6CCRB  ,CCRBI ,CCRI  ,CCRS  ,CCRSI ,CCTHB ,CCTHR ,CCWSTD,CCWTOL,
     7CCZT  ,CDEL  ,CDRRD ,CDTM  ,CDTW  ,CDTWT ,CDTWX ,CDTX  ,CDV   ,
     8CDVF  ,CDVI  ,CDVT  ,CDVXB ,CDVXM ,CDVXS ,CDVXZ ,CDVYB ,CDVYM ,
     9CDVYS ,CDVYZ ,CDVZB ,CDVZM ,CDVZS ,CDVZZ ,CDXD  ,CDXFD ,CDYD
      COMMON CDYFD ,CDZD  ,CDZFD ,CFX   ,CFY   ,CFZ   ,CM1   ,CM3   ,
     1CM4   ,CM5   ,CM6   ,CNPC  ,CNS   ,CNVX  ,CNVY  ,CNVZ  ,CNYC  ,
     2COEFF ,COINT ,COMGS ,CPHIB ,CPHIBC,CPSBCP,CPSIB ,CPSIBC,CPSIBM,
     3CR1   ,CRA   ,CRLO  ,CRR   ,CRRD  ,CRRG  ,CRRI  ,CRRPI ,CRS   ,
     4CSADPI,CSAPG ,CSAPI ,CSAPR ,CSPHIB,CSPSIB,CSPSIR,CSRDPI,CSRPG ,
     5CSRPI ,CSRPR ,CSRT  ,CSRTI ,CSTD  ,CSTOL ,CSTHB ,CSTHR ,CSTZ  ,
     6CSWSTD,CSWTDL,CT    ,CTD   ,CTDAS ,CTDV  ,CTHB  ,CTHBC ,CTHBCP,
     7CTHBM ,CTLRP ,CTM   ,CTR1  ,CTRR  ,CTTG  ,CTW   ,CTX   ,CUDPHS,
     8CUDPSS,CUDTHS,CWSTD ,CWSTDL,CWTTPR,CX    ,CXM   ,CXRD  ,CXSD  ,
     9CXT   ,CXTD  ,CXZ   ,CY    ,CYM   ,CYRD  ,CYSD  ,CYT   ,CYTD
      COMMON CYZ   ,CZ    ,CZM   ,CZRD  ,CZSD  ,CZT   ,CZTD  ,CZZ   ,
     1DELAY ,DONPRT,DT    ,DUM1  ,DUM2  ,DUM3  ,DUM4  ,DUM5  ,DUM6  ,
     2DUM7  ,DUM8  ,DUM9  ,DUM10 ,DUM11 ,DUM12 ,DUM13 ,DUM14 ,DUM15 ,
     3DUM16 ,DUMI7 ,DUMI8 ,FIN   ,FP    ,FXP   ,FXPP  ,FYP   ,FYPP  ,
     4FZP   ,FZPP  ,GC    ,IC    ,IEXIT ,IOLP  ,IWRITE,K2C   ,KC    ,
     5KWRITE,L     ,LC1   ,LC1J  ,LC2   ,LC3   ,LC4A  ,LC4B  ,LC4C  ,
     6LC4D  ,LC4E  ,LC4F  ,LC4G  ,LC5   ,LC7   ,LC8   ,LC10  ,LCA   ,
     7LCS   ,LCY   ,LDI00 ,LDI10 ,LDI11 ,LDI13 ,LDI20 ,LDI21 ,LDI22 ,
     8LDI25 ,LDI26 ,LDI31 ,LDO01 ,LDO05 ,LDO11 ,LDO12 ,LDO13 ,LDO62 ,
     9LDO63 ,LFDI  ,LQT   ,M     ,N     ,PHIB  ,PINT  ,PSIB  ,RDGD
      COMMON RRDREF,SRAA  ,SREA  ,SW    ,TEST  ,TFTXV ,TFTYV ,TFTZV ,
     1THETAB,TIME  ,TPC   ,TRI   ,TSC   ,TVX   ,TVY   ,TVZ   ,TYC   ,
     2XGRT  ,XGRTD ,XKRDR ,YGRT  ,YGRTD ,ZGRT  ,ZGRTD
      EQUIVALENCE (DELVX,CDVXSP),(DELVY,CDVYSP),(DELVZ,CDVZSP),
     1(CDPHSC,DPHIB),(CDPSSC,DPSIB),(CDTHSC,DTHB),(VLIST,CDVXSP)
1     IF (LDI11) 101,109,101
101   IF(LC4D) 113,102,113
102   LC4D=4095
      LC4C=0
103   CWTTPR=3.*3.14159265/2.
      CDEL=3.14159265/3.
      LC4A=0
      LC4B=0
      LC4E= 0
      LC4F=0
      LC4G=0
      LC24=4095
      LC24A=4095
      LC29=4095
      CLLO=0.
      DAS=CUREND
104   LC1=4095
      LC2=0
C
C     FROM PAGE 96 OF THE REPORT 
      LC3=0
      LC5=0
      LC7=0
      LC8=0
      IC=0
      K2C=0
      CTX=0.
      M=0
      LCA=0
      CTR1=-20.
      CTW=100.
      CDTX=100.
      CPSIBC=0.
      LCY=0
105   IF(IC-10) 106,106,108
106   CDTWT(IC+1)=-1.
107   IC=IC+1
      GO TO 105
108   IC=0
2     CALL GEXEC
109   IF(LC4C) 113,110,113
110   LC4C=4095
      LC4D=0
      GO TO 103
113   CTRR=CT-CTR1-20.
      IF(CTRR) 124,114,114
114   IF(CTRR-1.) 116,115,115
115   CRRD=9999.
      M=0
      CDRRD=9999.
116   LC10=0
      L=0
      CRA=0.
124   CALL GANG (CTHB,CPHIB,CPSIB,THETAB,PHIB,PSIB,CUDTHS,CUDPSS,CUDPHS,
     1CTHBC,CPSIBC)
126   CALL ERRANG (CUDPHS,CUDPSS,CUDTHS,CDPHSC,CDPSSC,CDTHSC)
128   CDTM=CAPT *CDEL/6.28318530
129   CSPHIB=SINF(CPHIB)
      CSPSIB=SINF(CPSIB)
      CSTHB=SINF(CTHB)
      CCPHIB=COSF(CPHIB)
      CCPSIB=COSF(CPSIB)
      CCTHB=COSF(CTHB)
130   CA11=CCPSIB * CCTHB
      CA12=-CCPSIB*CSTHB
      CA13=-CSPSIB
      CA21=CSTHB*CSPHIB-CCTHB*CSPSIB*CCPHIB
      CA22=CCTHB*CSPHIB+CSTHB*CSPSIB*CCPHIB
      CA23=-CCPSIB*CCPHIB
      CA31=CSTHB*CCPHIB+CCTHB*CSPSIB*CSPHIB
      CA32=CCTHB*CCPHIB-CSTHB*CSPSIB*CSPHIB
      CA33=CCPSIB*CSPHIB
132   IF (LC4B) 516,131,516
131   N=-1
133   LDO63=0
C
C     FROM PAGE 97 OF THE REPORT 
134   LDO01=4095
135   CALL WAIT5
136   IF(LDI00) 137,218,137
137   IF(N) 139,202,202
139   CRRI=TRI
      CSAPI=SREA
      CSRPI=SRAA
140   CSAPI=CSAPI+CCAB +CCAS *CSAPI
      CSRPI=CSRPI+CCRB +CCRS *CSRPI
141   IF(CRLO) 142,143,142
142   CSAPI=0.
      CSRPI=0.
      GO TO 145
143   IF(ABSF(CSRPI)-.4067366431) 144,218,218
144   IF(ABSF(CSAPI)-.4067366431) 145,218,218
145   IF(CRRI-XKRDR) 146,218,218
146   N=0
      GO TO 133
202   CRRPI=TRI
      CSADPI=SREA
      CSRDPI=SRAA
203   IF(ABSF(CRRPI-CRRI)-CCR ) 204,218,218
204   RDGD=0.
      CRRG =CRRI
      CSAPG=CSAPI
      CSRPG=CSRPI
205   IF(LC10) 219,206,219
206   L=L+1
207   CRA=CRA+CRRG
208   IF(L-5) 131,209,209
209   CRA=CRA/5.
210   IF(M) 212,211,212
211   M=1
      GO TO 216
212   CRRD=(CRA-CR1)/(CT-CTR1)
213   RRDREF=C0 +C2 *SQRTF(CRRG)
214   CDRRD =RRDREF-CRRD
216   CR1=CRA
      CTR1=CT
217   LC10=4095
      GO TO 2
218   RDGD=4095.
219   IF (K2C) 415,220,415
220   IF (3.14159265/6.+.05-CWTTPR) 227,221,221
221   IF (CT-(CTM+150.)) 227,222,222
222   IF(LC3) 223,227,223
223   LDO05=0
265   CDTW=0.
      GO TO 243
227   IF (LC1) 240,228,240
228   IF (LC4D ) 230,245,230
230   IF (LC7) 232,231,232
231   CTM=CT
232   IF (LC3) 247,233,247
233   IF (CTX- 750.) 234,235,235
234   LDO62=0
C
C     FROM PAGE 98 OF THE REPORT 
      GO TO 238
235   IF (LDI21) 333,238,333
238   CDTW=CT-(CTM+CTX)
      IF (CDTW) 239,241,241
239   IF (CDTW+50.)   2,240,240
240   CALL IVISZS (LDI22,LC5,CSTZ,CT,LDO11,LDO12,LDO13,CDVXZ,CDVYZ,
     1CDVZZ,LDI25,LDI26,LDI31,LC1,LC1J)
      GO TO 2
241   IF(CDTW-CTW) 243,242,242
242   CDTW=-1.
      GO TO 246
243   IF(RDGD)   2,244,  2
244   LC7=4095
245   CTLRP=CT
      CRR=CRRG
      CSAPR=CSAPG
      CSRPR=CSRPG
229   IF(LC4D) 246,509,246
246   CTX=CTX+CDTX
      GO TO 301
247   CTW=20.
      CDTX=20.
248   IF (LC2) 259,249,259
249   IF(CT-(CTM+150.)) 250,251,251
250   IF (CT-CTDV) 512,510,510
251   IF(CTX-150.) 252,253,253
252   CTD=200.
      GO TO 331
253   IF (CTX-330.) 254,255,255
254   CTHBC=CTHBM
      CPSIBC=CPSIBM
      GO TO 238
255   LC2=4095
256   LDO05=0
257   CPSIBC=0.
      CTHBC=0.
258   CX=CXM
      CY=CYM
      CZ=CZM
      GO TO 2
259   CDTW=CT-(CTM+CDTM)
      IF (CDTW) 260,241,241
260   IF(CDTW+80.) 240,261,261
261   IF(LC8) 262,263,262
262   CTD=CDTM-80.
      LC8=0
      GO TO 331
263   LDO05=4095
      GO TO 2
301   CSPSIR=-CSRPR
      CSTHR=    (CSAPR)/SQRTF(1.-CSRPR **2)
302   CCPSIR=SQRTF(1.-CSPSIR**2)
      CCTHR=SQRTF(1.-CSTHR**2)
303   CM1=CCPSIR*CCTHR
304   CM3=(CM1*CA11)+(CSPSIR*CA21)+(CSAPR*CA31)
      CM4=-(CM1*CA13)-(CSPSIR*CA23)-(CSAPR*CA33)
C
C     FROM PAGE 99 OF THE REPORT 
      CM5=(CM1*CA12)+(CSPSIR*CA22)+(CSAPR*CA32)
      CM6=CRR*(1.-CM5**2)/(2.*CSRT )
305   CX=CRR*CM3
      CY = CRR*(CM5-CM6)
      CZ=CRR*CM4
306   IF (CDTW) 311,307,307
307   CTHBM=6.28318530-ATN1F(CY,CX)
      CPSBCP=6.28318530-ATN1F(-CZ,SQRTF(CX**2+CY**2))
      CPSIBM=6.28318530-ATN1F(CY,SQRTF(CX**2+CZ**2))
308   IF (CTHBCP-3.14159265) 311,309,309
309   CTHBCP=CTHBCP-6.28318530
311   IF (3.14159265/6.+.05-CWTTPR) 313,312,312
312   IF(LC3) 316,314,316
313   IF(LC7) 316,314,316
314   LC7=4095
315   CTHBC=CTHBM
      CPSIBC=CPSIBM
      GO TO 2
316   IF (IC) 318,317,318
317   IC=10
      GO TO 319
318   IC=IC-1
319   CXT(IC+1)=CX
      CYT(IC+1)=CY
      CZT(IC+1)=CZ
      CDTWT(IC+1)=CDTW
      CDTWX=CDTW
320   CRS=CSRT +CY
      COMGS=SQRTF(1.407654E+16/CRS**3)
321   IF(LC2) 322,325,322
322   CWTTPR=CWTTPR-CDEL
323   IF (CDTW) 444,324,324
324   KC=0
      CSTD=CDTM-200.
      GO TO 401
325   IF (LC3) 2,326,2
326   IF (CTX- 750.) 2,327,327
327   CSTD=1000.
328   IF (CDTWX) 2,329,329
329   KC=IC
      GO TO 401
330   CTD=250.
331   CWSTD=COMGS*CTD
      CSWSTD=SINF(CWSTD)
      CCWSTD=COSF(CWSTD)
332   CH27=1./COMGS
      CH28=2./COMGS
      CH29=4./COMGS
      CX=CX+CH28*CYRD-3.*(CXRD-2.*COMGS*CY)*CTD+(CH29*CXRD-6.*CY)*CSWSTD
     1-CH28*CYRD*CCWSTD
      CY=4.*CY-CH28*CXRD+(CH28*CXRD-3.*CY)*CCWSTD+CH27*CYRD*CSWSTD
      CZ=CZ*CCWSTD+CH27*CZRD*CSWSTD
      GO TO 334
333   LCY=0
      LC3=4095
C
C     FROM PAGE 100 OF THE REPORT 
334   CSTD=1000.+CTD
335   IF(CTX-150.) 336,337,337
336   CTX=200.
      GO TO 338
337   IF (LC2) 338,328,338
338   LC7=0
      GO TO 307
401   LC1=4095
      CWSTDL=CWTTPR
      CXM=CX
      CYM=CY
      CZM=CZ
402   CSWTDL=SINF(CWSTDL)
      CCWTDL=COSF(CWSTDL)
      COEFF=COMGS/(3.*CWSTDL*CSWTDL-8.*(1.-CCWTDL))
403   CCK1=COEFF*CSWTDL
      CCK3=COEFF*2.*(1.-CCWTDL)
      CCK2=2.*COMGS+CCK3
404   CCKF=COEFF*(4.*CSWTDL-3.*CWSTDL*CCWTDL)
      CCKG=COMGS*CCWTDL/CSWTDL
405   IF (LC8)  408,406,408
406   LC8=4095
407   CCK4=CCKF
      CCK5=CCKG
      CCWTDL=1.
      GO TO 404
408   LC8=0
409   IF (LC1)  410,421,410
410   LC1=0
411   CDXFD=CCK1*CX+CCK3*CY
      CDYFD=-CCK3*CX+CCKF*CY
      CDZFD=-CCKG*CZ
      CDVF=SQRTF(CDXFD**2+CDYFD**2+CDZFD**2)
412   CXSD=0.
      CYSD=0.
      CZSD=0.
      CNS=0.
413   K2C=7
414   CXRD=CCK1*CX+CCK2*CY
      CYRD=CCK3*CX+CCK4*CY
      CZRD=-CCK5*CZ
415   IF (KC) 417,416,417
416   KC=10
      GO TO 418
417   KC=KC-1
418   CXZ=CXT(KC+1)
      CYZ=CYT(KC+1)
      CZZ=CZT(KC+1)
419   IF (CDTWT(KC+1)) 424,420,420
420   CSTDL=CSTD-(CDTWT(KC+1)-CDTWX)
      CWSTDL=CSTDL*COMGS
      GO TO 402
421   CXTD=(CXZ-CX)*CCK1+CYZ*CCK3+CY*CCK2
      CYTD=(CX-CXZ)*CCK3+CYZ*CCKF-CY*CCK4
      CZTD=CZ*CCK5-CZZ*CCKG
422   CXSD=CXSD+CXTD-CXRD
C
C     FROM PAGE 101 OF THE REPORT 
      CYSD=CYSD+CYTD-CYRD
      CZSD=CZSD+CZRD-CZTD
      CNS=CNS+1.
423   CDXD=CXSD/CNS
      CDYD=CYSD/CNS
      CDZD=CZSD/CNS
424   K2C=K2C-1
      IF (K2C) 425,427,425
425   CSTD=CSTD-CDTX
      GO TO 2
427   IF (LC2) 443,428,443
428   IF (CNS) 430,429,430
429   CDVT=0.
      GO TO 435
430   CDVI=SQRTF(CDXD**2+CDYD**2+CDZD**2)
431   CDVT =CDVI+CDVF
433   IF (CDVT-999.) 435,434,434
434   CDV=999.
      GO TO 436
435   CDV=INTF(CDVT)
436   IF (LC7) 437,439,437
437   LC7=0
438   CXRD=CXRD+DCXD
      CYRD=CYRD+CDYD
      CZRD=CZRD-CDZD
      GO TO 330
439   LC7=4095
440   IF(LC3) 501,441,501
441   CDVXSP=CDV
442   CDVXZ=CDV
      GO TO 2
443   IF (CNS) 445,444,445
444   CDXD=0.
      CDYD=0.
      CDZD=0.
445   LC2=0
446   IC=0
447   CTM=CTM+CDTM
448   IF (3.14159265/2.+.05-CWTTPR) 449,2,2
449   CDZD=0.
      GO TO 2
501   IC=0
502   CTM=CTLRP+CTD
503   CTDV=CTM-CDVI/(2.*CATXBA)
504   CPSIBC=6.28318530-ATN1F(CDZD,SQRTF(CDXD**2+CDYD**2))
      CPSBCP=6.28318530-ATN1F(CDZD,CDXD)
505   CTHBC=6.28318530-ATN1F(CDYD,CDXD)
      CPSBCP=6.28318530-ATN1F(CDYD,SQRTF(CDXD**2+CDZD**2))
506   IF(CTHBCP-3.14159265) 508,507,507
507   CTHBCP=CTHBCP-6.28318530
508   IF (LC48) 124,2,124
509   IF(LDI21) 510,504,510
510   LDO05=4095
512   CALL ALIGNP (CFX,CFY,CFZ,FXP,FYP,FZP,AKX1,AKX2,AKX3,AKX4,AKY1,
     1AKY2,AKY3,AKY4,AKZ1,AKZ2,AKZ3,AKZ4,DT)
513   CDVXM=CDVXM+CFX
C
C     FROM PAGE 102 OF THE REPORT 
      CDVYM=CDVYM+CFY
      CDVZM=CDVZM+CFZ
514   IF (LC8) 517,515,517
515   LC8=4095
516   CDVXM=-CDXD
      CDVYM=-CDYD
      CDVZM=-CDZD
517   CDVXB=-(CA11*CDVXM+CA12*CDVYM+CA13*CDVZM)
      CDVYB=-(CA21*CDVXM+CA22*CDVYM+CA23*CDVZM)
      CDVZB=-(CA31*CDVXM+CA32*CDVYM+CA33*CDVZM)
519   IF(LCA) 520,521,520
520   LC1J=-4095
521   CTX=100.
522   CALL IVIDS (CDVXS,CDVXB,CDVXZ,CDVYS,CDVYB,CDVYZ,CDVZS,CDVZB,
     1CDVZZ,LDI22,LC1J,LDO12,LDO13,CDV,CDVXSP,CDVYSP,CDVZSP)
      GO TO 2
      END(1,1,0,0,0,0,1,1,0,0,0,0,0,0,0)
